package cc.comac.saic.hkhy.jsrj.gj.inttools.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.saic.hkhy.jsrj.gj.inttools.entity.FileVersionInfo;
import cc.comac.saic.hkhy.jsrj.gj.inttools.service.FileVersionInfoService;

/**
 * 文件版本信息(FileVersionInfo)表控制层
 *
 * @author makejava
 * @since 2025-07-02 18:26:24
 */
@RestController
@RequestMapping("file-version")
public class FileVersionInfoController {
    @Autowired
    private FileVersionInfoService fileVersionInfoService;

    /**
     * 分页查询
     *
     * @param fileVersionInfo 筛选条件
     * @return 查询结果
     */
    @GetMapping
    public ResponseEntity<List<FileVersionInfo>> queryByCondition(FileVersionInfo fileVersionInfo) {
        return ResponseEntity.ok(this.fileVersionInfoService.queryByCondition(fileVersionInfo));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<FileVersionInfo> queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.fileVersionInfoService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param fileVersionInfo 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<FileVersionInfo> add(FileVersionInfo fileVersionInfo) {
        return ResponseEntity.ok(this.fileVersionInfoService.insert(fileVersionInfo));
    }

    /**
     * 编辑数据
     *
     * @param fileVersionInfo 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<FileVersionInfo> edit(FileVersionInfo fileVersionInfo) {
        return ResponseEntity.ok(this.fileVersionInfoService.update(fileVersionInfo));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Long id) {
        return ResponseEntity.ok(this.fileVersionInfoService.deleteById(id));
    }

}

